<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ include file="../taglibs.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>成绩管理</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<link  rel="stylesheet" type="text/css" href="css/four.css"/>
    <link rel="stylesheet" type="text/css" href="css/jqe/themes/default/easyui.css"/>
	<link rel="stylesheet" type="text/css" href="css/jqe/themes/icon.css"/>

    <script type="text/javascript" src="js/jquery-3.1.1.min.js"></script>
	<script type="text/javascript" src="js/jquery.easyui.min.js"></script>
    <script type="text/javascript" src="My97DatePicker/WdatePicker.js"></script>
    <script type="text/javascript">
        $(function(){
        	 //初始化对话框
        	   $('#dw,#dwEdit,#dwRead').window({
        		   onBeforeClose:function(){ 
        			   //取消时关闭等待框
        			   setTimeout(function(){ 
        				   sending.style.visibility = "hidden";
					   }, 250);
        	   }});
        	
       
              $(".btnAll").each(function(i,v){
        	   //变手型
        	     $(v).mouseover(function() {
    				$(this).css("cursor", "hand");
    			 }).mouseout(function() {
    				$(this).css("cursor", "pointer");
    			 });
        	   
        	   
        	   if($(v).html()=='【新增】'){
        		   $(v).click(function(){
        			   $('#dw').window("open");
        		   });
        	   }else if($(v).html()=='【编辑】'){
        		   $(v).click(function(){
        			   //ajax
        			  /*  $.get("ajOneCou.do?kcid="+ $(v).prop("lang")+"&x="+Math.random(),function(jsonTxt){
        				   var jsonObj = eval("("+jsonTxt+")");
        				   $("#upd_kcid").val(jsonObj.kcid);
        				   $("#upd_kcname").val(jsonObj.kcname);
        				   $("#upd_kcdesc").html(jsonObj.kcdesc);
        				   $('#dwEdit').window("open");
        			   }); */
        			   
        			   $.ajax({
        				   type:"POST",
        				   url:"ajOneGrade.do",
        				   data:"gid="+ $(v).prop("lang")+"&time="+new Date().getTime(),
        				   success:function(msg){
        					   if(msg.head='ok'){
        						   $("#upd_gid").val(msg.body.gid);
        						   $('#upd_cid').val(msg.body.cid);
                				   $('#dwEdit').window("open");
        					   }
        				   }
 
        			   });
        			   
        		   });
        	   }else if($(v).html()=='【删除】'){
        		   $(v).click(function(){
        			  if(confirm("确认删除分数?")){
        				  location.href="delGrade.do?gid="+$(v).prop("lang"); 
        			  }
        		   });
        	   }else if($(v).html()=='【查看】'){
        		   $(v).click(function(){
        			   $.ajax({
        				   type:"POST",
        				   url:"ajOneGrade.do",
        				   data:"gid="+ $(v).prop("lang")+"&time="+new Date().getTime(),
        				   success:function(msg){
        					   if(msg.head='ok'){
                				   $("#read_kgdesc").html(msg.body.grade);
                				   $('#dwRead').window("open");
        					   }
        				   }
        			   });
        		   })
        	   }
           }); 
        });
    </script>
</head>
<body>
<!-- 包含等待框 -->
	<jsp:include page="../waittable.jsp" flush="true" />
	<table width="100%" border="0" cellpadding="0" cellspacing="0">
		<tr valign="top">
			<td bgcolor="#FFFFFF">
			<table width="96%" border="0" align="center" cellpadding="4" cellspacing="1" bgcolor="#aec3de">
					<tr align="left" bgcolor="#F2FDFF">
						<td colspan="6" class="optiontitle">分数设置表</td>
					</tr>
					<tr align="center">
					     
					    <td align="center" bgcolor="#ebf0f7">课程名称</td>
						<td align="center" bgcolor="#ebf0f7">分数</td>
					
						<td align="center" bgcolor="#ebf0f7">登记时间</td>
						<td align="center" bgcolor="#ebf0f7">操作 <span class="btnAll">【新增】</span> <span id="del_all">【批量删除】</span></td>
					</tr>             
					<c:forEach items="${page.results}" var="g" >
					
						<tr align="center" bgcolor="#FFFFFF">
						<!-- 根据userid或用户身份显示当前用户成绩 -->
						<c:if test="${g.grade.userid == sessionScope.user.userid || sessionScope.user.role==1}">
						    <td align="center" >${g.course.cname }</td>
							<td align="center">${g.grade.grade }</td>
							<td align="center"><fmt:formatDate value="${g.grade.time}" pattern="yyyy-MM-dd" /></td>
							<td align="center">
							         <span class="btnAll" lang="${g.grade.gid}">【查看】</span>
									| <span class="btnAll" lang="${g.grade.gid}">【编辑】</span>
								    | <span class="btnAll" lang="${g.grade.gid }" title="${g.grade.gid }">【删除】</span>
				                  
							</td>
							</c:if>
						</tr>
						
					</c:forEach>
					<tr align="right" bgcolor="#ebf0f7">
							<td colspan="6">
							<jk:page totalPage="${page.totalPage}" pageNo="${page.pageNo}" totalRecord="${page.totalRecord}"
                                url="getAllGrade.do" />
							</td>	
					</tr>

	         </table>
	        </td>
	     </tr>
	 </table>
	 <div id="dwRead" class="easyui-window" title="查看分数" data-options="modal:true,minimizable:false,closed:true,maximizable:false,iconCls:'icon-save'" style="width:300px;height:200px;padding:10px;display: none;">
		 
		       课程分数 ：<textarea name="grade" rows="3" cols="30" id="read_kgdesc" disabled="disabled"></textarea><br/><br/>
	</div>
	
	<div id="dw" class="easyui-window" title="新添分数" data-options="modal:true,minimizable:false,closed:true,maximizable:false,iconCls:'icon-save'" style="width:300px;height:200px;padding:10px;display: none;">
		<form action="addGrade.do" method="post">
		 <input name="userid" value="${sessionScope.user.userid}" type="hidden"/>
		     课程编号：<input name="cid"/><br/><br/>
		    创建时间:<input name="time" onclick="WdatePicker({dateFmt:'yyyy-MM-dd'})"/> <br/><br/>
		     输入分数 ：<input name="grade" /><br/><br/>
		      <input type="submit" value="提交"/><br/>
		</form>
	</div>
	
	
	 <div id="dwEdit" class="easyui-window" title="修改分数" data-options="modal:true,minimizable:false,closed:true,maximizable:false,iconCls:'icon-save'" style="width:300px;height:200px;padding:10px;display: none;">
		<form action="updGrade.do" method="post">
		<input name="gid" id="upd_gid" type="hidden"/>
		<input name="userid"  value="${sessionScope.user.userid}" type="hidden"/>
		<input name="cid" id="upd_cid" type="hidden"  /><br/><br/>
		更改日期:<br/><input name="time"  onclick="WdatePicker({dateFmt:'yyyy-MM-dd'})" /> 
		  <br/><br/>
		     更改分数 ：<input name="grade" /><br/><br/>
		      <input type="submit" value="修改"/><br/>
		</form>
	</div>
</body>
</html>
